package com.poisonh.unifiedauth.ui.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.poisonh.unifiedauth.dao.UserinfoDaoImpl;
import com.poisonh.unifiedauth.model.UserInfoModel;
import com.poisonh.unifiedauth.utils.PreferencesUtils;

import java.util.List;

/**
 * Created by PoisonH on 2016/9/6.
 */
public abstract class BaseFragment extends Fragment
{
    /**
     * 用户id
     */
    protected String mStrUserId;
    protected String mStrUserToken;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        initUserData();
        return loadView(inflater, container, savedInstanceState);
    }

    private void initUserData()
    {
        try
        {
            mStrUserId = PreferencesUtils.getString(getActivity(), "ID");
            UserinfoDaoImpl mUserinfoDaoImpl = new UserinfoDaoImpl(getActivity());
            List<UserInfoModel> model = mUserinfoDaoImpl.queryReturnList(mStrUserId);
            mStrUserToken = model.get(0).getmStrToken();
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }


    protected abstract View loadView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
}
